package com.liwbn.rbac.support;

import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.web.servlet.view.AbstractView;

public class JsonView extends AbstractView {

    @Override
    protected void renderMergedOutputModel(Map<String, Object> map,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        response.setContentType("application/json;charset=UTF-8");
        ObjectMapper om = new ObjectMapper();
        PrintWriter out = response.getWriter();
        out.print(om.writeValueAsString(map));
    }

}
